#include<bits/stdc++.h>
using namespace std;
#define int long long
int d[100005],v0[100005],t[100005],a[100005],n,m,l,v;
vector<pair<int,int>> lis;
pair<int,int> cg(int l1,int r1){
    int fi,se;
    if(l1<=t[1]) fi=1;
    else fi=lower_bound(t+1,t+m+1,l1)-t;
    if(r1>=t[m]) se=m;
    else se=upper_bound(t+1,t+m+1,r1)-t-1;
    return {se,fi};
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    for(int yl=1;yl<=T;yl++){
        lis.clear();
        int sm=0;
        scanf("%lld%lld%lld%lld",&n,&m,&l,&v);
        for(int i=1;i<=n;i++)
            scanf("%lld%lld%lld",d+i,v0+i,a+i);
        for(int i=1;i<=m;i++)
            scanf("%lld",t+i);
        for(int i=1;i<=n;i++){
            if(a[i]==0){
                if(v0[i]>v&&d[i]<=t[m])
                    sm++,lis.push_back(cg(d[i],l));
            }
            else if(a[i]>0){
                if(v0[i]>v&&d[i]<=t[m])
                    sm++,lis.push_back(cg(d[i],l));
                else if(v0[i]<=v){
                    int g=(v*v-v0[i]*v0[i])+d[i]*2*a[i];
                    if(g<t[m]*2*a[i])
                        sm++,lis.push_back(cg((g+2*a[i])/(2*a[i]),l));
                }
            }
            else
                if(v0[i]>=v){
                    int g=(v*v-v0[i]*v0[i])+d[i]*2*a[i];
                    if(g<l*2*a[i]) g=l*2*a[i];
                    if(g%(2*a[i])==0) g+=2*a[i];
                    else g=g/(2*a[i])*2*a[i];
                    g/=2*a[i];
                    auto p=cg(d[i],g);
                    if(p.first>=p.second) sm++,lis.push_back(p);
                }
        }
        cout<<sm<<" ";
        sort(lis.begin(),lis.end());
        int last=0,ans=0;
        for(int i=0;i<lis.size();i++){
            if(last<lis[i].second)
                ans++,last=lis[i].first;

        }
        cout<<m-ans<<"\n";
    }
    return 0;
}
